package com.ww.basic

class CompanionExample {
  private val privateField: String = "private in class"
}

object CompanionExample {
  def accessPrivatedField(companion: CompanionExample): String = {
    companion.privateField // 伴生对象可以访问类的private成员
  }
}

object CompanionDemo {
  def main(args: Array[String]): Unit = {
    val example = new CompanionExample
    println(CompanionExample.accessPrivatedField(example))
  }
}
